" echom "提示: This is init.vimrc"

"===============================================================================
"
"-------------------------------------------------------------------------------

"  判断操作系统是否是 Windows 还是 Linux 
	let g:isWindows = 0
	let g:isLinux = 0
	let g:isMacVim = 0
	let g:isMac = 0
	if(has("win32") || has("win64") || has("win95") || has("win16"))
		let g:isWindows = 1
		" echo "提示:这是windows系统"
		" echom "提示:这是windows系统"
	elseif(has('gui_macvim') || has('mac'))
		let g:isMac = 1
		" echo "提示: 这是 MacOS 系统"
		" echom "提示: 这是 MacOS 系统"
	elseif(has('unix'))
		let g:isLinux = 1
		" echo "提示: 这是 Linux系统"
		" echom "提示: 这是Linux系统"
	else
		" echo "提示:这是Linux系统"
		echom "提示: 不知道是什么系统"
	endif

"  判断是终端还是图形界面 Gvim
	let g:isGUI = 0
	let g:isTerminal = 0
	" echo has('gui_running')
	if has("gui_running")
		let g:isGUI = 1
	elseif(has('gui_macvim'))
		let g:isGUI = 1
	else
		let g:isGUI = 0
	endif
	" echo has('terminal')
	if has("terminal")
		let g:isTerminal = 1
	else
		let g:isTerminal = 0
	endif

"  判断是vim 还是 nvim 
	let g:isVim = 0
	let g:isNeovim = 0
	if has("nvim")
		let g:isNeovim = 1
		" echo 'isNeovim'
		" echom 'isNeovim'
	else
		let g:isVim = 1
	endif

"  判断是 是否支持python 
	let g:isPython = 0
	let g:isPython = 0
	if has("nvim")
		let g:isPython = 1
		" echo 'isPython'
		" echom 'isPython'
	else
		let g:isPython = 1
	endif

"  判断是 是否支持python3
	" echo has('python3')
	let g:isPython3 = 0
	let g:isPython3 = 0
	if has("python3")
		let g:isPython3 = 1
		" echo 'isPython3'
		" echom 'isPython3'
	else
		let g:isPython3 = 1
	endif

" 使用举例
	" echo isWindows
	" if(isWindows)
	"     echo "isWindows = 1"
	"     " 执行该环境下的配置
	" else
	"     echo "isWindows = 0"
	"     echom "isWindows = 0"
	"     " 执行该环境下的配置
	" endif

" 判断是否是大文件
	" > 参考资料
	" + [如何提高 vim 打开 5G 以上大文件的性能](https://zhidao.baidu.com/question/1579658614753371820.html)
	" + [Linux打开编辑大文件](https://zhuanlan.zhihu.com/p/48787309)
	" + [vim 加载大文件的缓慢的问题](https://blog.csdn.net/LaineGates/article/details/78504884)
	" + [详谈Vim的配置层次结构与插件加载方式（一）](https://blog.csdn.net/qq_27825451/article/details/100518128)
	" + [vim8原生内置(naive)插件安装（二）](https://blog.csdn.net/qq_27825451/article/details/100557133)

	let g:isLargeFile = 0    " 1 代表是大文件标准，0 表示不是大文件标准
	" 设置大文件标准
	" (大于100M)
	" let g:LargeFileSize = 1024 * 1024 * 100
	" (大于10M)
	let g:LargeFileSize = 1024 * 1024 * 10
	" 获取打开文件的大小值

	augroup LargeFile
		:autocmd BufReadPre * let f=getfsize(expand("<afile>")) | if f > g:LargeFileSize || f == -2 | call LargeFile() | else | call NoLargeFile() | endif
	augroup END

	" 当符合大文件标准时
	function LargeFile()
		" no syntax highlighting etc
		set eventignore+=FileType
		" save memory when other file is viewed
		setlocal bufhidden=unload
		" is read-only (write with :w new_filename)
		" setlocal buftype=nowrite
		" no undo possible
		setlocal undolevels=-1
		" echom "This file is ".(getfsize(expand("<afile>"))/ 1024 / 1024) . "MB . It is larger than  " . (g:LargeFileSize / 1024 / 1024) . " MB."
		echom "该文件大小为 ".(getfsize(expand("<afile>"))/ 1024 / 1024) . "MB . 比设定的标准大小：" . (g:LargeFileSize / 1024 / 1024) . " MB 更大。判为大文件。"
		let g:isLargeFile = 1
		" echo "g:isLargeFile = ".g:isLargeFile
		" echom "g:isLargeFile = ".g:isLargeFile
	endfunction

	" 当不符合大文件标准时
	function NoLargeFile()
		" echom "The size of this file is ".(getfsize(expand("<afile>"))/ 1024 )." KB."
		echom "该文件大小为： ".(getfsize(expand("<afile>"))/ 1024 )." KB."
		let g:isLargeFile = 0
		" echo "g:isLargeFile = ".g:isLargeFile
		" echom "g:isLargeFile = ".g:isLargeFile
		" echom " 开启颜色插件"
		" 由于使用Plug插件时使用按需加载，所有要执行两次，一次为加载，一次为启动，
		
		"echom " 开启缩进指示插件"
		" 缩进指示线插件(疑似当打开的时大文件时会造成卡住),设置按需打开而非默认加载
	endfunction

"===============================================================================
"
